# cross.cmake文件
# 设置为1则表示交叉编译，设置为0则表示x86 gcc编译
SET(CROSS_COMPILE 1)

IF(CROSS_COMPILE)
SET(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSTEM_PROCESSOR loongson)
SET(TOOLCHAIN_DIR "/opt/loongson-gnu-toolchain-8.3-x86_64-loongarch64-linux-gnu-rc1.4/")
set(CMAKE_CXX_COMPILER ${TOOLCHAIN_DIR}/bin/loongarch64-linux-gnu-g++)
set(CMAKE_C_COMPILER ${TOOLCHAIN_DIR}/bin/loongarch64-linux-gnu-gcc)

SET(CMAKE_FIND_ROOT_PATH ${TOOLCHAIN_DIR})
SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)


# ...（原有工具链配置）

# 添加 OpenCV 路径（根据实际路径修改）
set(OPENCV_INSTALL_PATH "/usr/local")
    
# 将 OpenCV 路径加入 CMake 的搜索路径
list(APPEND CMAKE_PREFIX_PATH ${OPENCV_INSTALL_PATH})
    
# 指定 OpenCV 头文件和库的路径
set(OpenCV_DIR "${OPENCV_INSTALL_PATH}/lib/cmake/opencv4")  # 关键：指向 OpenCVConfig.cmake 所在目录

ENDIF(CROSS_COMPILE)